package cn.hrlly.tao2shou.biz;

import com.zhy.http.okhttp.OkHttpUtils;

import cn.hrlly.tao2shou.other.Config;
import cn.hrlly.tao2shou.callback.EditRequireCallback;
import cn.hrlly.tao2shou.domain.Require;
import cn.hrlly.tao2shou.listener.OnEditRequireListener;

/**
 * User: gengliang
 * Date: 2016-01-30
 * Time: 15:44
 */

public class EditRequireBizImpl implements EditRequireBiz {

    private OnEditRequireListener onEditRequireListener;

    public EditRequireBizImpl(OnEditRequireListener onEditRequireListener){
        this.onEditRequireListener=onEditRequireListener;
    }

    @Override
    public void alterRequire(Require require) {
        OkHttpUtils
                .post()
                .url(Config.key_url)
                .addParams(Config.key_action,Config.action_alter_require)
                .addParams(Config.key_release_id,require.getRequireId())
                .addParams(Config.key_require_title,require.getRequireTitle())
                .addParams(Config.key_require_description,require.getRequireDescription())
                .addParams(Config.key_acceptable_price, String.valueOf(require.getAcceptablePrice()))
                .build()
                .execute(new EditRequireCallback(onEditRequireListener));
    }

    @Override
    public void deleteRequire(Require require) {
        OkHttpUtils
                .post()
                .url(Config.key_url)
                .addParams(Config.key_action,Config.action_delete_require)
                .addParams(Config.key_require_id,require.getRequireId())
                .build()
                .execute(new EditRequireCallback(onEditRequireListener));
    }
}
